Component({
  options: {
    multipleSlots: true // 在组件定义时的选项中启用多slot支持
  },
  properties: {
    // 弹窗内容
    content: {
      type: String,
      value: '内容'
    },
  },

  data: {
    show: true,
    progress_txt: '',
    count: 1, // 设置 计数器 初始为0
    countTimer: null, // 设置 定时器 初始为null
    time: 0
  },

  ready: function () {
    this.circle = this.selectComponent("#circle1");
  },

  methods: {
    //隐藏弹框
    hidePopup: function () {
      clearInterval(this.countTimer);
      this.setData({
        show: true,
        count: 1,
        time: 0
      })
    },
    //展示弹框
    showPopup(content, duration) {
      let that = this
      clearInterval(this.countTimer);
      this.setData({
        show: false,
        progress_txt: content,
        count: 1,
        time: duration
      })
      that.countInterval(duration)
    },

    countInterval (duration) {
      let that = this
      that.countTimer = setInterval(() => {
        if (that.data.count < duration) {
          that.setData({
            time: duration - that.data.count++
          })
        } else {
          that.hidePopup()
        }
      }, 1000)
    },
  }
})